##TODO 操作mysql 数据库、  操作人大金仓  数据库。

import requests
## pip3 install beautifulsoup4
from bs4 import BeautifulSoup

## pip install mysql-connector-python
import mysql.connector

##人大金仓
import psycopg2

## Connect to the MYSQL --database
print("================================mysqlDB=========================")
conn = mysql.connector.connect(user='root', password='123456', host='127.0.0.1', database='test')
cursor = conn.cursor()
cursor.execute("select * from table1")
result = cursor.fetchall()
for row in result:
    print(row)

    ## Connect to the 人大金仓 --database
print("====================================kingDB=============================")
db = psycopg2.connect(database="sjfz", user="yujm", password="111111", host="192.168.2.188", port="54321")
# 得到一个可以执行SQL语句的光标对象
kingCursor = db.cursor()

db.autocommit = False  ## 关闭字自动提交
selectSql = "select * from sjfz3.sys_user_sj "
kingCursor.execute(selectSql)
kingResult = kingCursor.fetchall()
for kiongRow in kingResult:
    print(kiongRow)

    ## 返回数据库表的  列名
   ## ['user_id', 'dept_id', 'user_name', 'nick_name', 'user_type', 'email', 'phonenumber', 'sex', 'avatar', 'password', 'status', 'del_flag', 'login_ip', 'login_date', 'create_by', 'create_time', 'update_by', 'update_time', 'remark', 'area', 'division', 'idnumber', 'unit', 'police_code', 'dept_id_p']
    columnId = [kingResult[0] for kingResult in kingCursor.description]
    print(columnId)

#res = requests.get(url="https://zgztb.zbytb.com/v2/")
#print(res.text)
